<?php
/**
 * 查询分类
 */
require_once dirname(dirname(__DIR__))."/common.php";

use app\cls\tom\Response;
use app\cls\tom\SysResource;
use app\cls\tom\Tools;
use app\model\HomePage;

$db = SysResource::getDB(false);
//var_dump($db);exit;
$Home_page = new HomePage($db);
$page = isset($_REQUEST["page"]) ? intval($_REQUEST["page"]) : 1;
$page = $page > 0 ? $page : 1;
$pageSize = 30;
//查询分类
$datas=[];
$index=1;
$response = $Home_page->type();
if(!empty($response['data'])){
    foreach($response['data'] as $k=>$v){
        $res=$Home_page->all("user_material",['join_type'=>$v['id']],"id",$page,$pageSize);
        if(!empty($res)){
            $datas[]=$v;
        }

    }
}
Response::output(0,"查询成功",$datas,count($datas));